﻿Imports System.Threading
Imports System.IO
Public Class News
    Public Event NewsMessageSpawned(ByVal Message As String)
    Public Sub LoadNews()
        Try
            Try
                RaiseEvent NewsMessageSpawned("Getting Latest News from server....")
                My.Computer.Network.DownloadFile("http://pherein.servegame.org/news.txt", "news.txt", "", "", False, 10000, True)
            Catch ex As Exception
                Console.WriteLine("NEWS FUNCTION ERROR: " + ErrorToString())
            End Try
            If File.Exists("news.txt") Then
                Dim sr As StreamReader = File.OpenText("news.txt")
                While sr.EndOfStream <> True
                    RaiseEvent NewsMessageSpawned(sr.ReadLine)
                End While
                sr.Close()
            Else
                'No news is available.
                RaiseEvent NewsMessageSpawned("News could not be downloaded. Server may be down.")
            End If
            MainForm.n.Abort()
        Catch ex As Exception
            Console.WriteLine("NEWS FUNCTION ERROR: " + ErrorToString())
        End Try
    End Sub
End Class
